package xyz.zq.sf.auth.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

/**
 * 认证成功处理器
 *
 * @author hzq
 * @date 2021-02-07 15:20
 */
@Slf4j
@Component
public class SfAuthenticationSuccessEventHandler implements ApplicationListener<AuthenticationSuccessEvent> {


    @Override
    public void onApplicationEvent(AuthenticationSuccessEvent event) {
        Authentication authentication = (Authentication) event.getSource();
        log.info("登录成功：{}", authentication.getPrincipal());
    }
}
